package com.huawei.appmarket.service.settings.view.activity;

import android.os.Bundle;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.text.style.TypefaceSpan;
import android.view.View;
import com.huawei.appgallery.foundation.ui.framework.activity.BaseActivity;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.listener.IServerCallBack;
import com.huawei.appmarket.service.settings.bean.gameservice.ChangeGameServiceSettingRes;
import com.huawei.appmarket.service.settings.bean.gameservice.GetGameServiceSettingRes;
import huawei.widget.HwButton;
import huawei.widget.HwTextView;
import o.axh;
import o.ckl;
import o.ckl.c;
import o.BaseRequest;
import o.der.a;
import o.der.d;
import o.der.f;
import o.der.g;
import o.Logger;
import o.doo;
import o.eft;
import o.efu;
import o.egj;
import o.evk;
import o.evx;
import o.ewm.n;
import o.fbh;

public class SettingGameServiceActivity extends BaseActivity {
    private HwButton ˊॱ;
    private boolean ˋॱ = false;
    private boolean ॱˊ = false;

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        getWindow().setBackgroundDrawableResource(a.ᐝ);
        setContentView(g.ˋॱ);
        ॱ(getString(f.ॱᐧ));
        ॱˊ();
    }

    public void onResume() {
        super.onResume();
        ᐝ();
    }

    private void ᐝ() {
        if (this.ˊॱ == null) {
            return;
        }
        if (doo.ˊ(this)) {
            fbh.ˋ(efu.ˎ(), new IServerCallBack(this) {
                final /* synthetic */ SettingGameServiceActivity ˎ;

                {
                    this.ˎ = r1;
                }

                public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
                }

                public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
                    if ((responseBean instanceof GetGameServiceSettingRes) && responseBean.getResponseCode() == 0 && responseBean.getRtnCode_() == 0) {
                        boolean ˋ = this.ˎ.ˏ(((GetGameServiceSettingRes) responseBean).ˋ());
                        if (ˋ != this.ˎ.ˋॱ) {
                            this.ˎ.ˋॱ = ˋ;
                            this.ˎ.ͺ();
                        }
                    }
                }
            });
        } else {
            Logger.ˎ("SettingGameServiceActivity", "no active network");
        }
    }

    private int ˎ(boolean z) {
        return z ? 1 : 0;
    }

    private boolean ˏ(int i) {
        return i == 1;
    }

    private void ͺ() {
        if (this.ˊॱ == null) {
            Logger.ˋ("SettingGameServiceActivity", "gameServiceBtn == null");
        } else if (this.ˋॱ) {
            this.ˊॱ.setText(getString(f.ߵ));
        } else {
            this.ˊॱ.setText(getString(f.ॱꓸ));
        }
    }

    private void ॱˊ() {
        ᐝॱ();
        ʼॱ();
    }

    private void ᐝॱ() {
        ((HwTextView) findViewById(d.י)).setText(getString(f.ॱˍ, new Object[]{getString(f.ॱˑ)}));
        ((HwTextView) findViewById(d.ٴ)).setText(getString(f.ॱㆍ, new Object[]{getString(f.ॱˌ)}));
        ((HwTextView) findViewById(d.ـॱ)).setText(getString(f.ॱˉ, new Object[]{getString(f.ॱـ)}));
        String string = getString(f.ʿ);
        CharSequence spannableString = new SpannableString(getString(f.ॱˈ, new Object[]{string}));
        int indexOf = spannableString.toString().indexOf(string);
        ckl o_ckl = new ckl(this);
        egj.a aVar = new egj.a(this, 4, false);
        aVar.ˎ(axh.ˏ(this));
        o_ckl.ˏ(aVar.ˋ());
        spannableString.setSpan(o_ckl, indexOf, string.length() + indexOf, 33);
        spannableString.setSpan(new ForegroundColorSpan(getResources().getColor(a.ˋ)), indexOf, string.length() + indexOf, 33);
        spannableString.setSpan(new TypefaceSpan(getResources().getString(f.ˍ)), indexOf, string.length() + indexOf, 33);
        HwTextView hwTextView = (HwTextView) findViewById(d.ՙ);
        hwTextView.setText(spannableString);
        hwTextView.setMovementMethod(new c());
        hwTextView.setHighlightColor(getApplicationContext().getResources().getColor(a.ʼ));
    }

    private void ʼॱ() {
        this.ˊॱ = (HwButton) findViewById(d.ͺˎ);
        this.ˊॱ.setOnClickListener(new evx(this) {
            final /* synthetic */ SettingGameServiceActivity ˊ;

            {
                this.ˊ = r1;
            }

            public void ˋ(View view) {
                boolean z = false;
                if (doo.ˊ(this.ˊ)) {
                    SettingGameServiceActivity settingGameServiceActivity = this.ˊ;
                    if (!this.ˊ.ˋॱ) {
                        z = true;
                    }
                    settingGameServiceActivity.ॱˊ = z;
                    fbh.ˋ(eft.ˊ(this.ˊ.ˎ(this.ˊ.ॱˊ)), new IServerCallBack(this) {
                        final /* synthetic */ AnonymousClass2 ॱ;

                        {
                            this.ॱ = r1;
                        }

                        public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
                        }

                        public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
                            if ((responseBean instanceof ChangeGameServiceSettingRes) && responseBean.getResponseCode() == 0) {
                                if (responseBean.getRtnCode_() == 0) {
                                    this.ॱ.ˊ.ˋॱ = this.ॱ.ˊ.ॱˊ;
                                    this.ॱ.ˊ.ͺ();
                                    return;
                                } else if (responseBean.getRtnCode_() == -1) {
                                    evk.ˋ(this.ॱ.ˊ, this.ॱ.ˊ.getString(f.ॱᐨ), 0).ˋ();
                                    return;
                                }
                            }
                            evk.ˋ(this.ॱ.ˊ, this.ॱ.ˊ.getString(f.ˋʽ), 0).ˋ();
                        }
                    });
                    return;
                }
                evk.ˏ(this.ˊ, n.ʹˊ, 0).ˋ();
            }
        });
    }
}
